
<template>
  <div>
      <el-select :style="{width:width}" clearable @change="changevt" placeholder="请选择" ref="ddlreqitemclassSelect" v-model="myvalue">
          <el-option :key="item.itemclasscode" :label="item.itemclassname" :value="item.itemclasscode" v-for="item in seloptions">
              <span style="float: left;font-weight: bold;" v-if="item.havechild == '1'">{{ item.itemclassname }}</span>
              <span style="float: left;padding-left:10px;" v-else>{{ item.itemclassname }}</span>
          </el-option>
      </el-select>
  </div>
</template>
<script>
export default {
  //props: ["width", "value"],
  props: {
      width: { type: String },
      value: { type: String },
      //authflag: { type: String, default: "0" },
  },
  watch: {
      value(newVal) {
          this.myvalue = newVal;
      },
      myvalue(newVal) {
          this.$emit("input", newVal);
      },
  },
  data() {
      return {
          myvalue: this.value,
          fulldata: null,
          seloptions: [],
      };
  },
  computed: {},
  methods: {
      changevt: function (evt) {
          let cData = this.fulldata;
          if (evt != "") {
              cData = cData.filter((item) => item.itemclasscode === evt);
          }
          this.$emit("change", evt, cData[0]);
          this.$emit("changeObj", {code:evt, name:'', row:cData[0]});
      },
      loadAllData: function () {
          this.$tool
              .request({
                  url: "ucent/ddl",
                  method: "post",
                  data: {
                      action: "reqitemclass",
                      // authflag: this.authflag,
                  },
              })
              .then((res) => {
                  // console.log("res", res);
                  this.fulldata = res;
                  this.seloptions = this.fulldata;
                  // console.log("seloptions", this.seloptions);
              })
              .catch((e) => {
                  console.log("erro", e);
              });
      },
  },
  mounted() {
      this.loadAllData();
  },
};
</script>
<style scoped>
.el-aside {
  color: #333;
}
</style>